package com.itheima.MyThreadPoolDemo;

public class Demo2 {
    public static void main(String[] args) {
        GirlThread girl = new GirlThread();
        girl.start();

        while(true){
            if(GirlThread.money != 10){
                System.out.println("滚蛋");
                break;
            }
        }
    }

}
class GirlThread extends Thread {
    //volatile强制查看共享数据
    public static volatile int money = 100;

    @Override
    public void run() {
        try {
            Thread.sleep(100);
            money -= 5;
            System.out.println("女孩看了下钱还剩"+money+"元");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}